/**
 * DiggApiNet - Digg API .NET Wrapper
 * 
 * Author: Sean Hickey
 * Link: http://www.headzoo.com/digg_api_net
 * License: GPL v2 ( http://www.gnu.org/licenses/gpl.txt )
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace DiggApiNet
{
    public class DiggStory : DiggReturnBase
    {
        public long             Id
        {
            get
            {
                XmlNode node = (XmlNode)_dict["story"];
                return long.Parse(node.Attributes["id"].InnerText);
            }
        }
        public string           Link
        {
            get
            {
                XmlNode node = (XmlNode)_dict["story"];
                return node.Attributes["link"].InnerText;
            }
        }
        public DateTime         SubmitDate
        {
            get
            {
                XmlNode node = (XmlNode)_dict["story"];
                return GetDateTimeFromTimeStamp(node.Attributes["submit_date"].InnerText);
            }
        }
        public int              Diggs
        {
            get
            {
                XmlNode node = (XmlNode)_dict["story"];
                return int.Parse(node.Attributes["diggs"].InnerText);
            }
        }
        public int              Comments
        {
            get
            {
                XmlNode node = (XmlNode)_dict["story"];
                return int.Parse(node.Attributes["comments"].InnerText);
            }
        }
        public string           Href
        {
            get
            {
                XmlNode node = (XmlNode)_dict["story"];
                return node.Attributes["href"].InnerText;
            }
        }
        public string           Title
        {
            get
            {
                XmlNode node = (XmlNode)_dict["title"];
                return node.InnerText;
            }
        }
        public string           Description
        {
            get
            {
                XmlNode node = (XmlNode)_dict["description"];
                return node.InnerText;
            }
        }
        public DiggUser         User
        {
            get
            {
                XmlNode node = (XmlNode)_dict["user"];
                return new DiggUser(node);
            }
        }
        public DiggContainer    Container
        {
            get
            {
                XmlNode node = (XmlNode)_dict["container"];
                return new DiggContainer(node);
            }
        }
        public DiggTopic        Topic
        {
            get
            {
                XmlNode node = (XmlNode)_dict["topic"];
                return new DiggTopic(node);
            }
        }

        public DiggStory(XmlDocument xml_doc) : this(xml_doc.SelectSingleNode("stories").SelectSingleNode("story"))
        {
            
        }
        public DiggStory(XmlNode node) : base(node)
        {

        }

        public override string ToString()
        {
            return Title;
        }
    }
}
